package com.joe.bibackend.service.impl;

import com.alibaba.excel.EasyExcel;
import com.joe.bibackend.bean.dto.ChartResponseDTO;
import com.joe.bibackend.response.NormalResponse;
import com.joe.bibackend.service.ChartService;
import com.joe.bibackend.utils.AIUtils;
import com.joe.bibackend.utils.ExcelUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@Service
public class ChartServiceImpl implements ChartService {

    @Override
    public Map<String,String> getChartResponseFromAI(String chartType, String goal, MultipartFile file) {
        StringBuilder chartRequest = new StringBuilder();
        chartRequest.append(goal+"请按的格式写相应echarts代码，图像选择："+chartType+"。仅仅回复代码，不要有任何开头，结尾，注释并注意仅仅是echarts V5的option配置对象。以下是数据的csv：/n");
        String inputCVS = ExcelUtil.convertExcelToCVS(file);
        chartRequest.append(inputCVS);
        return AIUtils.askAliChart(chartRequest.toString());
    }
}
